package com.aacar.controller;

import com.aacar.dto.*;
import com.aacar.entity.Order;
import com.aacar.interceptor.MemLoginKeyValid;
import com.aacar.service.MemberOrderService;
import com.aacar.service.WasherOrderService;
import com.aacar.utils.ResultInfoUtil;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RestController
@RequestMapping("/washerorder")
public class WasherOrderController extends ValidController{
	private Logger logger = LoggerFactory.getLogger(this.getClass());
    
	@Resource
	private WasherOrderService washerOrderService;

	@Autowired
	private  HttpServletRequest request;



	@RequestMapping(value = "/list/0", method = RequestMethod.POST)
	@ResponseBody
	@MemLoginKeyValid
	public Object list(@RequestBody WasherOrderListDto washerOrderListDto){
		logger.info("request:/washerrorder/list/0" + JSONObject.toJSONString(washerOrderListDto));

		Header mobileHead = super.getMobileHead(request);
		washerOrderListDto.setWashUserId(Long.valueOf(mobileHead.getUserId()));

		return ResultInfoUtil.setSuccessInfo(washerOrderService.getWasherOrderListPage(washerOrderListDto),mobileHead.getService());
	}


	@RequestMapping(value = "/detail/0", method = RequestMethod.POST)
	@ResponseBody
	@MemLoginKeyValid
	public Object list(@RequestBody Order order){
		Header mobileHead = super.getMobileHead(request);
		logger.info("request:/washerrorder/detail/0" + JSONObject.toJSONString(order));
		return ResultInfoUtil.setSuccessInfo(washerOrderService.getWasherOrderDetail(order.getOrderNo()),mobileHead.getService());
	}


	@RequestMapping(value = "/receorder/0", method = RequestMethod.POST)
	@ResponseBody
	@MemLoginKeyValid
	public Object receOrder(@RequestBody ReceOrderDto receOrderDto){
		Header mobileHead = super.getMobileHead(request);
		logger.info("request:/washerrorder/receorder/0" + JSONObject.toJSONString(receOrderDto));
		return ResultInfoUtil.setSuccessInfo(washerOrderService.getWasherOrderDetail(receOrderDto.getOrderNo()),mobileHead.getService());
	}




   
}
